#include "common.hpp"

int main()
{
  // 打开管道文件
  int fd = open(FILE_NAME, O_WRONLY);
  if (fd == -1)
  {
    perror("open");
    exit(FILE_OPEN_ERR);
  }

  // 开始通信
  string line;
  while (true)
  {
    // char buffer[1024] = {0};
    // cin >> buffer;
    cout << "Client say@ ";
    getline(cin, line);
    // int n = write(fd, buffer, sizeof(buffer));
    int n = write(fd, line.c_str(), line.size());
    if (n < 0)
      return -1;
  }

  // 关闭管道文件
  close(fd);

  return 0;
}